package com.candy.homework;

/**
 * @author donglin
 * @Title:
 * @类名: HourlyEmployee
 * @date 2020/7/24
 */
public class HourlyEmployee extends ColEmployee {
    //HourlyEmployee ：ColaEmployee 的子类，
    // 按小时拿工资的员工，每月工作超出160 小时的部分按照1.5 倍工资发放。
    // 属性：每小时的工资、每月工作的小时数
    double hourSalary;
    int hourNum;

    public HourlyEmployee() {
    }

    public HourlyEmployee(String name, int month, double hourSalary, int hourNum) {
        super(name, month);
        this.hourSalary = hourSalary;
        this.hourNum = hourNum;
    }

    @Override
    public double getSalary(int month) {
        if(super.month==month){
            if (this.hourNum>160){
                return (((this.hourSalary)*160)+((hourNum-160)*hourSalary*1.5))+100;
            }else {
                return (this.hourSalary*this.hourNum)+100;
            }

        }
        else {
            if (this.hourNum>160){
                return (((this.hourSalary)*160)+((hourNum-160)*hourSalary*1.5));
            }else {
                return (this.hourSalary*this.hourNum);
            }

        }

    }
}
